<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ page contentType="text/html;charset=utf-8" import="com.cs.beneficios.common.ConnectionFactory,com.cs.paoyer.administration.business.model.UserVO,com.cs.beneficios.common.entity.Consultas,java.sql.Connection,java.sql.ResultSet,java.sql.SQLException,com.cs.beneficios.common.entity.database"%>

<%UserVO user = (UserVO)session.getAttribute("userInfo");%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Consultar Programa</title>
  <script language="JavaScript" src="<%= request.getContextPath() + "/js/popUPdesc.js" %>"></script>
   <script language="javascript">
    function activarvalor(locacion1)
    {
      document.form.action=locacion1;
      document.form.submit();
    }
    
    function flimpiar()
    {
      document.form.Programa.value = "";
    }
    
    function flimpiar1()
    {
      document.form.secretaria.value = "";
    }

    
   </script>
     
  </head>
  <body>
  <%
    request.setCharacterEncoding("utf-8");
  %>
  <link href="<%= request.getContextPath() + "/css/bloques.css" %>" rel="stylesheet" type="text/css">
  <DIV align="center">
    <table cellspacing="2" cellpadding="1" border="0" width="80%">
      <tr>
        <td align="center" class="titulosenblanco">ADMINISTRACI&Oacute;N&nbsp;DE PROGRAMAS</td>
      </tr>
    </table>
  </DIV>
    <P align="center">
        <table width="60%" border="0" cellpadding="0" cellspacing="0" align="center">
      <tr><td>
      <table width="30%" border="0" cellpadding="0" cellspacing="0" align="right">
          <tr/>
          <tr>
            <td align="right">
              <html:link page="/programas/IngresarPrograma.do">
                <img src="<%= request.getContextPath() + "/images/b_nuevo.gif" %>" alt="Nuevo" width="22" height="22" border="0"/>
                <br/>
              </html:link>
              <strong>Nuevo Programa</strong>
            </td>
           <td>&nbsp;</td>
          <td>&nbsp;</td>
            <td align="center" width="40%">
              <% String Ruta2 = "'"+request.getContextPath() + "/programas/ActivarProgramas.do'"; %>
              <input type="image" onclick="activarvalor(<%=Ruta2%>)" src="<%= request.getContextPath() + "/images/activar.gif" %>"/>
              <strong>Activar Programas</strong>
           </td> 

          </tr>
        </table>
        </td></tr>
      </table>
        
    </P>
    <DIV align="center">
    <form name="form" method="get" action="<%= request.getContextPath() + "/programas/ConsultarPrograma.do" %>">
    <table cellspacing="3" cellpadding="3" border="0" align="center" width="100">
    <tr>
        <td width="2%" colspan="3">
          <P align="center" class="celdatabla">Seleccione un criterio para consultar  programas</P>
        </td>
      </tr>
      <tr>
        <td width="2%">&nbsp;</td>
        <td width="17%" class="celdatabla">
          <P>
            <STRONG>Programa</STRONG>
            </P>
        </td>
        <td>
          <input type="text" class="form" name="Programa" value="" onchange="flimpiar1()" maxlength="50" size="50"/>
        </td>
      </tr>
        
<%  
   //ConnectionFactory cf = new ConnectionFactory("beneficios","beneficios");
   ConnectionFactory cf = new ConnectionFactory();
   Consultas consulta = new Consultas(cf);
    Connection conn = cf.getConnection();
   database db = new database();
   ResultSet rs = null;
   String strsecretaria = request.getParameter("secretaria");
    rs = consulta.getNomSecretaria();
    
    if(rs != null){%>
          <tr>
            <td width="2%">&nbsp;</td>
            <td width="17%" class="celdatabla">
              <STRONG>Secretaria</STRONG>
            </td>
            <td width="79%">
             
            <select name="secretaria" class="formLista" onchange="flimpiar()"/>
            <option value="" class="form">SELECCIONE LA SECRETARIA</option>
              <%try{
                 while(rs.next()){
                 if(strsecretaria != null){
                 if(strsecretaria.equals(rs.getString("codigo"))){%>
                 <option class="formLista" selected="selected" value="<%=rs.getString("codigo")%>"><%=rs.getString("nombre")%></option>
                 <%}else{%>
                 <option class="formLista" value="<%=rs.getString("codigo")%>" ><%=rs.getString("nombre")%></option>
                 <%}
                 }else{%>
                 <option class="formLista" value="<%=rs.getString("codigo")%>" ><%=rs.getString("nombre")%></option>
                <%}
                }%> 
                 </select>
                 <%}catch(SQLException e){}
                 cf.closeConnection(conn);
                 %>
            </td>
          </tr>
       <%}else{%>
            <tr>
            <td colspan="3">Ocurrio un error</td>
            </tr>
          <%}%>
     <tr>
        <td colspan="4">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="4">
          <DIV align="center">
            <input type="submit" value="Consultar" />
          </DIV>
        </td>
      </tr>
    </table>
  <P><%
        if(session.getAttribute("mensajes") != null){
          out.println((String)session.getAttribute("mensajes"));
        }
          session.removeAttribute("mensajes");
      %>
  </P>
    
  
   <table  cellspacing="3" cellpadding="2" border="0" width="90%" align="center">

    <tr>
    <td>
    <logic:notPresent scope="request" name="programas">
        <DIV align="center"><%=request.getAttribute("msg")%></DIV>
    </logic:notPresent>
    <logic:present scope="request" name="programas"> 
        <display:table name="requestScope.programas"  requestURI='<%= request.getContextPath() + "/programas/ConsultarPrograma.do" %>' class="bordesTable" pagesize="20" id="pro" cellpadding="3" cellspacing="1"  style="width:100%">
            <display:column headerClass="headerTable" title="Programa" class="Numero" sortable="false">
              <html:link paramId="Codigo" paramName="pro" paramProperty="code" page="/programas/ModificarPrograma.do">
                <bean:write name="pro" property="nombre" /> 
              </html:link> 
            </display:column>
            <display:column headerClass="headerTable" title="Area" class="Numero" sortable="false">
                <bean:write name="pro" property="nombreArea" /> 
            </display:column>
            <display:column headerClass="headerTable" title="Modificar" class="Numero">
              <html:link paramId="Codigo" paramName="pro" paramProperty="code" page="/programas/ModificarPrograma.do">
                   <div align="center"><img src="<%= request.getContextPath() + "/images/modificar.gif" %>" width="16" height="16" border="0"></div>
              </html:link>       
          </display:column>	
          <bean:define id="Codigo" name="pro" property="code"></bean:define>
          <bean:define id="codsecret" name="pro" property="codeArea"></bean:define>
                <%
                  java.util.HashMap params = new java.util.HashMap();
                  params.put("Codigo", Codigo);
                  params.put("ori","consulprog");
                  params.put("codsecret",codsecret);
                  pageContext.setAttribute("parametros", params);
                %>
          <display:column headerClass="headerTable" title="Nuevo Beneficio" class="Numero">
              <html:link name="parametros" scope="page" page="/subprogramas/IngresarSubprograma.do">
                   <div align="center"><img src="<%= request.getContextPath() + "/images/nuevo.gif" %>" width="16" height="16" border="0"></div>
              </html:link>       
          </display:column>	
          <display:column headerClass="headerTable" title="Desactivar" class="Numero">
          <bean:define id="Programa" name="pro" property="code"></bean:define>
              <a onclick="return confirm('Esta seguro que desea desactivar el Programa?')" href='javascript:vpopUsers("<%=request.getContextPath()+"/jsp/programas/RazonDesactivar.jsp"%>?Programa=<%=Programa%>");'>
              <div align="center"><img src="<%= request.getContextPath() + "/images/Delete.gif" %>" width="16" height="16" border="0"></div></a>
          </display:column>	
        </display:table>
      </logic:present>
      </td>
    </tr>
    <input type="hidden" name="Codigo">
  </table>
  </form>
  </DIV>
  <% cf.closeConnection(consulta.getConn());%>
 </body>
</html>
